class Index extends eui.Component implements  eui.UIComponent {
	public constructor() {
		super();
		this.skinName = "IndexSkin";
	}

	protected partAdded(partName:string,instance:any):void
	{
		super.partAdded(partName,instance);
	}

	private ballAni;	//球的动画
	private explain;	//活动说明
	private group;		//点击向上箭头执行的动画
	private gruopDown;	//点击向下箭头执行的动画
	private ball;
	private isShow = true;
	static sound:egret.Sound;
	static soundChannel:egret.SoundChannel;

	protected childrenCreated():void
	{
		super.childrenCreated();
		this.playAnimation(this.ballAni,true);

		this.explain.touchEnabled = true;
		this.explain.addEventListener(egret.TouchEvent.TOUCH_TAP,()=>{
			if(this.isShow){
				this.isShow = !this.isShow;
				this.group.play(-1);
				this.ball.touchEnabled = false;
			}else{
				this.isShow = !this.isShow;
				this.gruopDown.play(-1);
				this.ball.touchEnabled = true;
			}
		})

		Index.sound = RES.getRes("beijing_mp3"); 
        Index.soundChannel = Index.sound.play();
		this.ball.once(egret.TouchEvent.TOUCH_BEGIN,()=>{
			SceneManager.createObj(this.stage).loadScene("startgame",StartGame);
		})
	}

	//设置循环播放
	private playAnimation(target: egret.tween.TweenGroup, isLoop: boolean): void {
		if (isLoop) {
			for (var key in target.items) {
				target.items[key].props = { loop: true};
			}
		}
		target.play();
	}
}